﻿Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace DotNetNuke.Modules.ActiveForums.Controls
    <DefaultProperty("Text"), ToolboxData("<{0}:CategoryNavigator runat=server></{0}:CategoryNavigator>")> _
    Public Class CategoryNavigator
        Inherits WebControl
        Private _itemTemplate As DisplayTemplate
        Public Property ItemTemplate() As DisplayTemplate
            Get
                Return _itemTemplate
            End Get
            Set(ByVal Value As DisplayTemplate)
                _itemTemplate = Value
            End Set
        End Property
        Private _headerTemplate As DisplayTemplate
        Public Property HeaderTemplate() As DisplayTemplate
            Get
                Return _headerTemplate
            End Get
            Set(ByVal Value As DisplayTemplate)
                _headerTemplate = Value
            End Set
        End Property
        Private _footerTemplate As DisplayTemplate
        Public Property FooterTemplate() As DisplayTemplate
            Get
                Return _footerTemplate
            End Get
            Set(ByVal Value As DisplayTemplate)
                _footerTemplate = Value
            End Set
        End Property
        Private _renderMode As Integer = 0
        Public Property RenderMode() As Integer
            Get
                Return _renderMode
            End Get
            Set(ByVal value As Integer)
                _renderMode = value
            End Set
        End Property
        Public Property PortalId() As Integer = -1
        Public Property ModuleId() As Integer = -1
        Public Property TabId() As Integer = -1
        Public Property ForumId() As Integer = -1
        Public Property ForumGroupId() As Integer = -1
        Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
            Dim tb As New Controls.CategoriesList(PortalId, ModuleId, ForumId, ForumGroupId)
            tb.TabId = TabId
            tb.Template = ItemTemplate.Text
            tb.HeaderTemplate = HeaderTemplate.Text
            tb.FooterTemplate = FooterTemplate.Text
            tb.CSSClass = CssClass
            If Not HttpContext.Current.Request.QueryString("act") Is Nothing AndAlso IsNumeric(HttpContext.Current.Request.QueryString("act")) Then
                tb.SelectedCategory = Integer.Parse(HttpContext.Current.Request.QueryString("act"))
            End If
            If RenderMode = 0 Then
                writer.Write(tb.RenderView())
            Else
                writer.Write(tb.RenderEdit())
            End If

        End Sub

    End Class
End Namespace

